<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<head>
<title>EPrice ~ Listado de Productos</title>
<link href="<bean:write name="path"/>/css/estilos.css" rel="stylesheet" type="text/css"/>
</head>
<%
String str_cliente = request.getParameter("str_cliente");
%>
<script language="javascript" type="">
function buscarValor( campo, valor ){
	var int_retVal = -1;
	for( var int_i=0; int_i < campo.length; int_i++ ){
		if( campo[int_i].value == valor ){
			int_retVal = int_i;
			break;
		}
	}
	return int_retVal;
}
function enviaParam(str_codigo, str_descripcion,str_clase, str_segmento,str_gerente, int_diasExp){
  try{
    window.opener.document.getElementById('str_codigoProducto').value=str_codigo;
    window.opener.document.getElementById('str_descProducto').value=str_descripcion;
		window.opener.document.getElementById('str_gerente').value=str_gerente;
		window.opener.fnc_diasExpiracion( int_diasExp );
		var campo = window.opener.document.getElementById('str_segmentoXCliente');
		var campoH = window.opener.document.getElementById('str_segmentoXClienteH');
		var int_index = buscarValor( campo ,str_segmento );
		if( int_index > 0 ){
			campo.selectedIndex = int_index;
			campo.disabled = true;
			campoH.value = str_segmento;
		}else{
			campo.selectedIndex = 0;
			if( '<%=str_cliente%>' == '' ){
				campo.disabled = true;
			}else{
			campo.disabled = false;
			}
		}
		var logi = window.opener.document.getElementById('int_logistica');
		var logiH = window.opener.document.getElementById('int_logisticaH');
		if( str_clase != "Agroproductos" ){
			logi.disabled = true;
			logi.selectedIndex = 3;
			logiH.value = 102;
			window.opener.document.getElementById('hdn_agro').value = false;
		}else{
			logi.disabled = false;
			logi.selectedIndex = 0;
			window.opener.document.getElementById('hdn_agro').value = true;
		}


		try{
			window.opener.int_subsegmento.value = str_segmento;
			window.opener.fnc_subsegmento();
		}catch(e){
			alert(e);
		}
    window.opener.focus();
  }catch(e){
    alert(e);
  }finally{
    window.close();
  }
}
</script>
<body>
<html:form action="buscarProducto" method="get" focus="str_search">
  <html:hidden property="service" value="listarProducto"/>
  <html:hidden property="str_cliente" value="<%=str_cliente%>"/>
  <br>
  <table width="80%" border="0" align="center" cellpadding="0" cellspacing="1" class="tabla">
  <tr class="encabezadoTabla">
    <td colspan="3">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="30">&nbsp;<img width="17" height="23" src="<bean:write name="path"/>/images/img_loginFlecha.gif" alt=""/></td>
          <td>&nbsp;&nbsp;<strong class="font_general">Listado de Productos  </strong></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td height="0" colspan="3"></td>
  </tr>
  <tr class="encabezado_col font_general">
    <td colspan="3" align="center">Producto:&nbsp;&nbsp;
      <html:text styleClass="textfield" property="str_search"/>&nbsp;&nbsp;&nbsp;
      <html:submit styleClass="boton" value="Buscar" property="btn_buscar"/>
    </td>
  </tr>
  <tr>
    <td height="0" colspan="3"></td>
  </tr>
  <tr>
    <td width="9%" align="center" class="encabezado_col font_general">&nbsp;</td>
    <td width="14%" align="center" class="encabezado_col font_general">Codigo</td>
    <td width="77%" align="center" class="encabezado_col font_general">Descripcion</td>
  </tr>
  <logic:iterate id="producto" name="arrL_producto" indexId="int_i">
    <tr>
      <td align="center" class="font_general <%=int_i.intValue()%2==0?"":"im"%>par"><a href="#" onclick='enviaParam("<bean:write name='producto' property='str_codProd'/>", "<bean:write name='producto' property='str_descProd'/>", "<bean:write name='producto' property='str_claseProd'/>", "<bean:write name='producto' property='str_segmentoXCliente'/>", "<bean:write name='producto' property='str_gerente'/>", "<bean:write name='producto' property='int_diasExp'/>");'><img width="15" height="15" border="0" src="<bean:write name="path"/>/images/img_add.gif" alt=""/></a></td>
      <td align="center" class="font_general <%=int_i.intValue()%2==0?"":"im"%>par"><bean:write name="producto" property="str_codProd"/></td>
      <td align="left" class="font_general <%=int_i.intValue()%2==0?"":"im"%>par">&nbsp;<bean:write name="producto" property="str_descProd"/></td>
    </tr>
  </logic:iterate>
</table>
  <br>
</html:form>
</body>
</html:html>
